1. Field of the Invention
The present invention relates to a method of compiling a source program to generate a mechanical level program (hereinafter referred to as the target program), particularly to a method in which the target program can be generated in accordance with a type of processor (hereinafter referred to as the target processor) for operating the target program from one source program. The present invention also relates to a device for realizing the method, a recording medium in which a program for allowing a computer to execute a processing based on the method is stored, and a recording medium in which a conversion table for use in the processing based on the method is recorded.
2. Description of the Related Art
An example of a conventional compiling system is described in Japanese Patent Application Laid-Open No. Hei 6-332719. The compiling system will briefly be described as a first conventional example with reference to FIG. 13. FIG. 13 is a flowchart showing the first conventional example.
In the first conventional example, when an intermediate language code command is generated from a source program, and a code of target program is generated from the intermediate language code command, code generation means is used. A generation code table comprising at least one generation code pattern (generation code with a header attached thereto), and a content of change of the generation code pattern (dependent on program) are transmitted to the code generation means. Additionally, the header attached to the generation code indicates what change is made on the generation code.
In the compiling system, a compiler code generation device successively fetches the generation code pattern from the generation code table. Subsequently, the change content dependent on program is developed in a code in accordance with the type of the header attached to the generation code, which is formed into a code to be generated.
According to the system, for different target processors, the compiler code generation device can be prepared only by changing the content of the generation code table.
In the first conventional compiling system, however, a command for each target processor is described in the generation code table (conversion table), excluding a section in which the change content dependent on program is developed. Therefore, all generation code patterns need to be described using the command for each target processor.
As a result, in the system, in order to generate the compiler code generation device for a plurality of target processors, generation code tables need to be individually prepared for the types of target processors. Specifically, every time the target processor is changed, all the generation code patterns have to be changed. When a large number of types of target processors are to be handled, the amount of the generation code table is enormously increased, and an amount of operations necessary for generating the generation code table is disadvantageously increased.
Moreover, when the type of the target processor is changed, not only the generation code pattern but also the way of developing the change content dependent on program into the generation code are influenced. The influence is caused by a difference in architecture of the target processor. For an example of difference of architecture, in determinations of a loop upper or lower bound repeated integer times, a comparison command including an equal sign is used in some target processor, while a comparison command excluding the equal sign is used in the other target processor. In this case, an immediate value forming the loop upper or lower bound value may vary in the generation code in accordance with the type of the target processor.
In this respect, in the first conventional system, the way of developing the change content dependent on program into the generation code is limited to the way designated as a header type. Therefore, the first conventional system can only be used for a target processor group of a limited type in which the way of development is the same as a source program format. For example, in the system, a program (target program) for a microprocessor manufactured by a specified maker can be generated, but a program for a microprocessor manufactured by another maker cannot be generated. Therefore, the first conventional system has a problem that the types of target processors are limited.
Another example of the conventional compiling system is described in Japanese Patent Application Laid-Open No. Hei 4-14144. The compiling system will briefly be described as a second conventional example with reference to FIG. 14. FIG. 14 is a functional block diagram showing the second conventional example.
A compiler 100 for realizing the compiling system comprises a semantic analysis processing section 200 independent of architecture, general-purpose intermediate language optimization processing section 210, architecture-dependent processing section 220, intermediate language optimization processing section 230, code generation processing section 240, intermediate language skeleton table 120, and code generating skeleton table 130.
In the compiling system, compiling is performed as follows:
First, in the semantic analysis processing section 200, a semantic analysis processing of inputted source program 110 is performed, and a general-purpose intermediate language 140 independent of architecture is outputted. Subsequently, in the general-purpose intermediate language optimization processing section 210, if necessary, a conversion for optimization of general-purpose intermediate language is performed, and results are outputted as an optimized general-purpose intermediate language 150.
Subsequently, in the second conventional example, a processing dependent on architecture related with a conventional semantic analysis is performed in the architecture-dependent processing section 220. In the processing, an intermediate language 160 dependent on computer architecture is generated from the optimized general-purpose intermediate language 150 using the intermediate language skeleton table 120. Subsequently, in the intermediate language optimization processing section 230, the intermediate language 160 is optimized to output an optimized intermediate language 170. Subsequently, in the code generation processing section 240, a target program 180 comprising a machine language command sequence and the like is generated from the optimized intermediate language 170 using the code generating skeleton table 130.
As described above, in the second conventional compiling system, a high-performance object is generated by separating the processing dependent on computer architecture from the semantic analysis processing.
In the second conventional compiling system, however, the architecture-dependent section is separated from the semantic analysis processing. Therefore, every time the architecture is changed, the intermediate language skeleton table needs to be changed.
Moreover, in the same manner as the first prior art, also in the system, the code generating skeleton table (conversion table) is described with the command of the target processor. Therefore, description needs to be provided using each target processor command for each generation code pattern.
As a result, also in the system, for a plurality of target processors, the code generating skeleton table needs to be separately prepared for each type of target processor. Specifically, every time the target processor is changed, all code generating skeleton tables need to be changed. As a result, when a large number of types of target processors are to be handled, the amount of the code generating skeleton table disadvantageously becomes enormous. Furthermore, when the amount of code generating skeleton table is enormous, the amount of operations necessary for preparing the code generating skeleton table is disadvantageously increased.